package com.example.aicompositiongrader.model;

import java.util.ArrayList;
import java.util.List;

public class CompositionResponse {
    private String originalText; // 学生原文
    private List<Correction> corrections; // 基础纠错
    private List<String> optimizationSuggestions; // 优化建议
    private OverallEvaluation overallEvaluation; // 整体评价
    private String referenceEssay; // 参考范文
    private List<String> improvementDirections; // 新增：改进方向

    // 构造方法，初始化集合和对象，避免null值
    public CompositionResponse() {
        this.corrections = new ArrayList<>();
        this.optimizationSuggestions = new ArrayList<>();
        this.improvementDirections = new ArrayList<>(); // 初始化改进方向列表
        this.overallEvaluation = new OverallEvaluation();
    }

    // 基础纠错模型
    public static class Correction {
        private int startIndex;
        private int endIndex;
        private String originalText;
        private String correctedText;
        private String errorType; // 错误类型：错别字/语法错误等
        private String reason; // 修改原因

        // 默认构造方法
        public Correction() {}

        // Getters and Setters
        public int getStartIndex() { return startIndex; }
        public void setStartIndex(int startIndex) { this.startIndex = startIndex; }
        public int getEndIndex() { return endIndex; }
        public void setEndIndex(int endIndex) { this.endIndex = endIndex; }
        public String getOriginalText() { return originalText; }
        public void setOriginalText(String originalText) { this.originalText = originalText; }
        public String getCorrectedText() { return correctedText; }
        public void setCorrectedText(String correctedText) { this.correctedText = correctedText; }
        public String getErrorType() { return errorType; }
        public void setErrorType(String errorType) { this.errorType = errorType; }
        public String getReason() { return reason; }
        public void setReason(String reason) { this.reason = reason; }

        @Override
        public String toString() {
            return "Correction{" +
                    "errorType='" + errorType + '\'' +
                    ", originalText='" + originalText + '\'' +
                    ", correctedText='" + correctedText + '\'' +
                    '}';
        }
    }

    // 整体评价模型
    public static class OverallEvaluation {
        private int themeScore; // 主题明确性（1-5星）
        private int structureScore; // 结构完整性
        private int languageScore; // 语言表达
        private int emotionScore; // 情感真实性
        private String comment; // 评价文字

        // 默认构造方法
        public OverallEvaluation() {}

        // Getters and Setters
        public int getThemeScore() { return themeScore; }
        public void setThemeScore(int themeScore) { this.themeScore = themeScore; }
        public int getStructureScore() { return structureScore; }
        public void setStructureScore(int structureScore) { this.structureScore = structureScore; }
        public int getLanguageScore() { return languageScore; }
        public void setLanguageScore(int languageScore) { this.languageScore = languageScore; }
        public int getEmotionScore() { return emotionScore; }
        public void setEmotionScore(int emotionScore) { this.emotionScore = emotionScore; }
        public String getComment() { return comment; }
        public void setComment(String comment) { this.comment = comment; }

        @Override
        public String toString() {
            return "OverallEvaluation{" +
                    "themeScore=" + themeScore +
                    ", structureScore=" + structureScore +
                    ", languageScore=" + languageScore +
                    ", emotionScore=" + emotionScore +
                    ", comment='" + comment + '\'' +
                    '}';
        }
    }

    // Getters and Setters
    public String getOriginalText() { return originalText; }
    public void setOriginalText(String originalText) { this.originalText = originalText; }
    public List<Correction> getCorrections() { return corrections; }
    public void setCorrections(List<Correction> corrections) { this.corrections = corrections; }
    public List<String> getOptimizationSuggestions() { return optimizationSuggestions; }
    public void setOptimizationSuggestions(List<String> optimizationSuggestions) { this.optimizationSuggestions = optimizationSuggestions; }
    public OverallEvaluation getOverallEvaluation() { return overallEvaluation; }
    public void setOverallEvaluation(OverallEvaluation overallEvaluation) { this.overallEvaluation = overallEvaluation; }
    public String getReferenceEssay() { return referenceEssay; }
    public void setReferenceEssay(String referenceEssay) { this.referenceEssay = referenceEssay; }

    // 新增：改进方向的Getters和Setters
    public List<String> getImprovementDirections() { return improvementDirections; }
    public void setImprovementDirections(List<String> improvementDirections) {
        this.improvementDirections = improvementDirections;
    }

    @Override
    public String toString() {
        return "CompositionResponse{" +
                "originalText='" + originalText + '\'' +
                ", corrections.size=" + corrections.size() +
                ", optimizationSuggestions.size=" + optimizationSuggestions.size() +
                ", improvementDirections.size=" + improvementDirections.size() +
                ", referenceEssay.length=" + (referenceEssay != null ? referenceEssay.length() : 0) +
                '}';
    }
}
